%% Example submission: Naive Bayes

%% Set up libraries

%addpath libsvm
addpath liblinear

%cd spider
%use_spider
%cd ..


%% Load the data
% Run this before calling method routines so they can use it

load ../data/data_no_bigrams.mat;

% Preprocess, prune stopwords
%{
prune_cv;
prune_cv_test;
% Load pruned data
%load pruned_vocab
%load pruned_train
%load pruned_test
%}

% Make word count training data
X = make_sparse(train);
Y = double([train.rating]');

% Make word count test data
Xtest = make_sparse(test, size(X, 2));


% Make title and helpful rating data.
% Generates matrices XtestHelpTitle, XhelpTitle
run_new_features;
% Load made data
%load extraFeatures


%% USE WITH CAUTION. To save memory. If functions later uses these, need to
%   comment out, but funcs shouldn't need it, data is already loaded above.

% Comment out this block if running on CV data. Uncomment the same block
%   below, after making CV data.
clear train
clear test



%% Naive Bayes - on real data

%run_nb_all;



%% Liblinear SVM - on real data

run_liblinear_all;


%% Unsupervised learning - on real data

%run_pca_all;


%% Generative Model - Modified Naive Bayes Decision Tree

%run_nbdt;

%% Instance Method Learning - KNN
%run_knn_all;


%% Make our own test/training set
% Run this before calling method routines so they can use it

% XcvTrain = make_sparse(train(bsxfun(@gt, [train().category], 6)));
% YcvTrain = double([train(bsxfun(@gt, [train().category], 6)).rating])';
% 
% XcvTest = make_sparse(train(bsxfun(@lt, [train().category], 7)));
% YcvTest = double([train(bsxfun(@lt, [train().category], 7)).rating])';
% 
% % Make title / helpful rating data
% % Generates matrices XcvTestHelpTitle, XcvTrainHelpTitle
% 
% % Create features data on test set
% run_new_features_cv


%% USE WITH CAUTION. To save memory. If functions later uses these, need to
%   comment out, but funcs shouldn't need it, data is already loaded above.
% clear train
% clear test
% clear vocab


%% Naive Bayes - on CV data

%run_nb_cv;


%% Unsupervised - on CV data

% K-means clustering - on CV data
%  Uses Spider library.
%run_kmeans;

% Random projections
%run_pca_cv;


%% Liblinear SVM - on CV data

% Run this for our CV data
%CVscript;
